package top.leinx.fxnotes.control;

/**
 * @Author : xiaolei
 * @DateTime: 2021/3/25 9:44 上午
 */

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;

public class CheckBoxExample extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        CheckBox checkBox1 = new CheckBox("CheckBox 1");
        checkBox1.setAllowIndeterminate(true);

        Button button = new Button("显示CheckBox状态");
        button.setOnAction(event -> {
            System.out.println("checkBox1.indeterminate = " + checkBox1.isIndeterminate());
            System.out.println("checkBox1.selected = " + checkBox1.isSelected());
        });

        CheckBox checkBox2 = new CheckBox("CheckBox2");
        checkBox2.setOnAction(event -> {
            System.out.println("checkBox2.indeterminate = " + checkBox2.isIndeterminate());
            System.out.println("checkBox2.selected = " + checkBox2.isSelected());
        });

        HBox box = new HBox(10.0);
        box.getChildren().addAll(checkBox1, button, checkBox2);

        primaryStage.setTitle("CheckBox 示例");
        primaryStage.setScene(new Scene(box, 400, 200));
        primaryStage.show();

    }
}
